﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="login.aspx.cs" Inherits="UI.system.login" %>
<%@ Import Namespace="Common" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>登录</title>
    <script src="/js/jquery.min.js"></script>
    <script src="/js/common.js"></script>
    <script src="/js/md5.js"></script>
    <script src="/js/jquery.cookies.min.js"></script>
    <script src="/system/layui/layui.js"></script>
	<link rel="stylesheet" href="/system/layui/css/layui.css">
	<link rel="stylesheet" href="/system/css/login.css" />
</head>

<body class="beg-login-bg" onkeyup='CRM.Enter("#login")'>
		<div class="beg-login-box">
			<header>
				<h1><%=config.WebName %></h1>
			</header>
			<div class="beg-login-main">
				<form class="layui-form" method="post">
					<div class="layui-form-item">
						<label class="beg-login-icon">
                        <i class="layui-icon">&#xe612;</i>
                    </label>
						<input type="text" id="username" name="username" lay-verify="username" autocomplete="off" placeholder="这里输入登录名" class="layui-input" onkeyup='CRM.Enter("#login")'>
					</div>
					<div class="layui-form-item">
						<label class="beg-login-icon">
                        <i class="layui-icon">&#xe642;</i>
                    </label>
						<input type="password" id="userpwd" name="userpwd" lay-verify="userpwd" autocomplete="off" placeholder="这里输入密码" class="layui-input" onkeyup='CRM.Enter("#login")'>
					</div>
					<div class="layui-form-item">
						<div class="beg-pull-left beg-login-remember">
							<label>记住密码&nbsp;</label>
							<input id="rememberme" type="checkbox" name="rememberme" value="true" lay-skin="switch" <%=CookieHelper.GetCookie("admin_rememberme")=="true"?"checked":"" %> title="记住帐号">
						</div>
						<div class="beg-pull-right">
							<a id="login" class="layui-btn layui-btn-primary" lay-submit lay-filter="login">立即登录</a>
						</div>
						<div class="beg-clear"></div>
					</div>
				</form>
			</div>
			
		</div>
		<script>
		    layui.use(['layer', 'form'], function () {
		        var layer = layui.layer,
				form = layui.form;
		        form.verify({
		            username: function (value) {
		                if (value == "") {
		                    return '用户名不能为空';
		                }
		            },
		            userpwd: function (value) {
		                if (value == "") {
		                    return '密码不能为空';
		                }
		            }
		        });
		        form.on('submit(login)', function (data) {
		            var field = data.field;
		            var data = {};
		            data.act = "Login";
		            data.username = field.username;
		            data.userpwd = field.userpwd;
		            data.rememberme = $("#rememberme").prop("checked");
		            data.sign = GetSign(data.act);
		            var index = LayerBox.Loading();
		            Ajax.Post("/tools/Admin.ashx", data, function (r) {
		                LayerBox.Close.ByIndex(index);
		                var json = $.parseJSON(r);
		                if (json.state) {
		                    LayerBox.Success(json.msg, 500, function () {
		                        window.location.href = "index.aspx";
		                    });
		                }
		                else {
		                    LayerBox.Error(json.msg);
		                }
		            });
		        });

		    });

		    $(document).ready(function () {
		        setTimeout(function () {
		            $("#username").val($.cookies.get("admin_username"));
		            $("#userpwd").val($.cookies.get("admin_userpwd"));
		        }, 500);
		    });
		</script>
</body>
</html>
